﻿using Wicresoft.ARConnector;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Wicresoft.CustomerAttributes;
using Wicresoft.Entity.AREntity;

namespace Wicresoft.Test
{


    /// <summary>
    ///This is a test class for ARProxyTest and is intended
    ///to contain all ARProxyTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ARProxyTest
    {


        private TestContext testContextInstance;
        private ARProxy<Wicresoft.Entity.AREntity.People> arProxy;


        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
            string userName = "Demo"; // TODO: Initialize to an appropriate value
            string password = "asb#1234"; // TODO: Initialize to an appropriate value
            string serverName = "vs31srm01"; // TODO: Initialize to an appropriate value
            string authentication = ""; // TODO: Initialize to an appropriate value
            arProxy = new ARProxy<Wicresoft.Entity.AREntity.People>(userName, password, serverName, authentication);
            //arProxy.Login();
        }
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Login
        ///</summary>
        public void LoginTestHelper<T>()
        {
            string userName = "Demo"; // TODO: Initialize to an appropriate value
            string password = "asb#1234"; // TODO: Initialize to an appropriate value
            string serverName = "vs31srm01"; // TODO: Initialize to an appropriate value
            string authentication = ""; // TODO: Initialize to an appropriate value
            ARProxy<T> target = new ARProxy<T>(userName, password, serverName, authentication); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            // actual = target.Login();
            // Assert.AreEqual(expected, actual);
            // Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void LoginTest()
        {
            LoginTestHelper<People>();
        }



        /// <summary>
        ///A test for CreateEntry
        ///</summary>
        public void CreateEntryTestHelper<T>()
        {
            PrivateObject param0 = null; // TODO: Initialize to an appropriate value
            ARProxy_Accessor<People> target = new ARProxy_Accessor<People>(param0); // TODO: Initialize to an appropriate value
            //T entity = default(T); // TODO: Initialize to an appropriate value
            // People p = new People { Id = "1", Name = "weiwei" };
            // target.CreateEntry(p);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        [TestMethod()]
        [DeploymentItem("Wicresoft.ARConnector.dll")]
        public void CreateEntryTest()
        {
            CreateEntryTestHelper<GenericParameterHelper>();
        }

        [TestMethod]
        public void Create_Entry_Test()
        {
            //string userName = "Demo"; // TODO: Initialize to an appropriate value
            //string password = "asb#1234"; // TODO: Initialize to an appropriate value
            //string serverName = "vs31srm01"; // TODO: Initialize to an appropriate value
            //string authentication = ""; // TODO: Initialize to an appropriate value
            //ARProxy<People> proxy = new ARProxy<People>(userName, password, serverName, authentication);
            //proxy.Login();
            // People p = new People { Id = "1", Name = "weiwei" };
            Wicresoft.Entity.AREntity.People people = new Entity.AREntity.People
            {
                CIL = "wdwei",
                EmployeeID = "cvxxxxxxxx",
                Name = "weiwei",
                Password = "User@123",
                Status = "1",
                Company = "wicresoft",
                Telephone = "13956554588",
                ClientType = 2000,
                LastName = "wei",
                FirstName = "FirstName",
                LicenseType = 2,
                SupportStaff = 1
            };
            // arProxy.EnableTransaction = true;
            arProxy.CreateEntry(people);
        }

        [TestMethod]
        public void Delete_Entry_Test()
        {
            // People p = new People { Id = "000000000000004" };
            Wicresoft.Entity.AREntity.People people = new Entity.AREntity.People
            {
                PeopleId = "PPL000000124006",
                CIL = "wdwei",
                EmployeeID = "cvxxxxxxxx",
                Name = "weiwei",
                Password = "User@123",
                Status = "1",
                ProfileStatus = 5
            };
            arProxy.RemoveEntry(people);
        }

        [TestMethod]
        public void Update_Entry_Test()
        {
            // People p = new People { Id = "000000000000002",Name="CMDBss" };
            Wicresoft.Entity.AREntity.People people = new Entity.AREntity.People
            {
                PeopleId = "PPL000000124006",
                CIL = "wdweisss",
                EmployeeID = "cvxxxxxxxx",
                Name = "weiwei",
                Password = "User@123",
                Status = "1",
                Company = "wicresoftsss",
                Telephone = "13956554588",
                ClientType = 2000,
                LastName = "weiss",
                FirstName = "FirstName",
                LicenseType = 2,
                SupportStaff = 1,
                ProfileStatus = 5
            };
            arProxy.UpdateEntry(people);
            
        }

        #region class stub
        //[ARForm("ASB_CMDBTestForTommy")]
        //public class People
        //{
        //    [AREntryId]
        //    public string Id { get; set; }

        //    [ARField(536870914, ARDataType.Character)]
        //    public string Name { get; set; }

        //    #region Must entry field
        //    [ARField(2, ARDataType.Character)]
        //    public string Submitter
        //    {
        //        get { return "Tommy"; }
        //    }

        //    [ARField(7, ARDataType.Integer)]
        //    public string Status
        //    {
        //        get { return "0"; }
        //    }

        //    [ARField(8,ARDataType.Character,MaxLength=1)]
        //    public string Description
        //    {
        //        get { return "Testing"; }
        //    }


        //    #endregion
        //}

        #endregion
    }
}
